<%@page pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="keys" content="">
    <meta name="author" content="">
	<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" href="css/backstage/font-awesome.min.css">
	<link rel="stylesheet" href="css/backstage/login.css">
	<style>

	</style>
  </head>
  <body>
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <div><a class="navbar-brand" href="index.html" style="font-size:32px;">天天生鲜-后台</a></div>
        </div>
      </div>
    </nav>

    <div class="container">
      <h1 style="color:red">${param.errorMsg}</h1>
      <form id="loginForm"  method="post" class="form-signin" role="form">
        <h2 class="form-signin-heading"><i class="glyphicon glyphicon-user"></i> 工作人员登录</h2>
		  <div class="form-group has-success has-feedback">
			<input type="text" class="form-control" id="loginacct" name="loginacct" placeholder="请输入登录账号" autofocus>
			<span class="glyphicon glyphicon-user form-control-feedback"></span>
		  </div>
		  <div class="form-group has-success has-feedback">
			<input type="text" class="form-control" id="userpswd" name="userpswd" placeholder="请输入登录密码" style="margin-top:10px;">
			<span class="glyphicon glyphicon-lock form-control-feedback"></span>
		  </div>
<%--        <div class="checkbox">--%>
<%--          <label>--%>
<%--            <input type="checkbox" value="remember-me"> 记住我--%>
<%--          </label>--%>
<%--          <br>--%>
<%--          <label>--%>
<%--            忘记密码--%>
<%--          </label>--%>
<%--        </div>--%>
        <a class="btn btn-lg btn-success btn-block" onclick="dologin()" > 登录</a>
      </form>
    </div>
    <script src="jquery/jquery-2.1.1.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <script src="layer/layer.js"></script>
    <script>
    function dologin() {
     var loginacct = $("#loginacct").val();
     //表单的值只要能取到那他就不会为空，在没有赋值的情况下他的值为空字符串 ""
     if (loginacct==""){
         layer.msg("用户名不能为空",{time:2000,icon:0,shift:5});
         return;
     }
     var userpswd = $("#userpswd").val();
     if (userpswd==""){
         layer.msg("密码不能为空",{time:2000,icon:0,shift:5});
         return;
     }
      //提交表单
      //alert("提交表单");
      // $("#loginForm").submit();
        var loadingIndex = null;
        $.ajax({
            type:"post",
            url:"doAJAXLogin",
            data:{
                "loginacct":loginacct,
                "userpswd":userpswd
            },
            beforeSend : function(){
                loadingIndex = layer.msg('处理中', {icon: 16});
            },
            success:function (result){
                layer.close(loadingIndex);
                if(result.success){
                    window.location.href = "index";
                }else{
                    layer.msg("用户登录账号或密码不正确，请重新输入", {time:2000, icon:5, shift:6}, function(){
                    });
                }
            }
        });
    }
    </script>
  </body>
</html>